import { Controller, Get, Post, Body, Patch, Param, Delete, Inject } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto, SelectUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@Controller('user')
@ApiTags('用户管理')
export class UserController {

  @Inject()
  private readonly userService: UserService;

  @Post()
  @ApiOperation({
    summary: '查询所有用户',
  })
  findAll(@Body() selectUserDto: SelectUserDto) {
    return this.userService.findAll(selectUserDto);
  }

  @Get(":id")
  @ApiOperation({
    summary: '查询单个用户',
  })
  findById(@Param('id') id: string) {
    return this.userService.findOne(id);
  }

  @Patch(":id")
  @ApiOperation({
    summary: '修改用户',
  })
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(id, updateUserDto);
  }

  @Delete(":id")
  @ApiOperation({
    summary: '删除用户',
  })
  remove(@Param('id') id: string) {
    return this.userService.remove(id);
  }
}
